<template>
    <div class="con">
        <img src="../assets/images/logo.png" alt="" class="logo" onclick="return false">
        <img src="../assets/images/pic_CashTicket.png" alt="" onclick="return false">
        <input type="num" class="number" v-model="number">
        <input type="text" class="type" v-model="type">
        <input type="num" class="num" v-model="count"> 
        <img src="../assets/images/btn_cash.png" alt="" class="btn" @click.prevent="checkCash()">        
    </div>
</template>

<script>
export default {
    name: "gift",
    data() {
        return {
            number: "",
            type: "",
            count: ""
        };
    },
    beforeCreate() {
        document.getElementsByTagName("body")[0].className = "bg_MyPoints";
    },
    methods: {
        checkCash() {
            if (this.number == "") {
                alert("现金票号码不能为空");
            } else if (this.type == "") {
                alert("现金票类型不能为空");
            } else if (this.count == "") {
                alert("人数不能为空");
            } else {
                var qs = require("qs");
                this.axios({
                    method: "post",
                    url: `${this.siteUrl}/piaowu/api/check_order_cash`,
                    data: qs.stringify({
                        member_id: $.cookie("osc_member_id"),
                        token: $.cookie("osc_member_token"),
                        staff_id: localStorage.getItem("staff_id"),
                        staff_token: localStorage.getItem("staff_token"),
                        number: this.number,
                        type: this.type,
                        count: this.count
                    })
                })
                    .then(response => {
                        if (response.data.status == 1) {
                            alert(response.data.data.msg);
                            this.number = "";
                            this.type = "";
                            this.count = "";
                        } else {
                            alert("请求失败：" + response.data.msg);
                        }
                    })
                    .catch(function(error) {
                        console.log(error);
                    });
            }
        }
    },
    mounted: function() {}
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.con {
    text-align: center;
    position: relative;
}
.con img {
    width: 100%;
}
.con .logo {
    width: 34%;
    position: absolute;
    left: 50%;
    transform: translate(-50%, 30%);
}
.con .number {
    position: absolute;
    width: 40%;
    left: 50%;
    top: 49.5%;
    border: 1px solid #000;
    height: 22px;
}
.con .type {
    position: absolute;
    width: 40%;
    left: 50%;
    top: 65%;
    border: 1px solid #000;
    height: 22px;
}
.con .num {
    position: absolute;
    width: 40%;
    left: 50%;
    top: 80%;
    border: 1px solid #000;
    height: 22px;
}
.con .btn {
    position: absolute;
    width: 30%;
    right: 6%;
    bottom: -10%;
}
</style>
